{include file='public/meta'}
  <title>角色管理 - 角色编辑 - 木鱼内容管理系统</title>
</head>
<body>
  <div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">角色</label>
      <div class="layui-input-block">
          <!--隐藏字段-->
          <input type="hidden" name="id" value="{$roles.id}" />
        <input type="text" name="name" id="name" placeholder="请输入角色名称" value="{$roles.name}" class="layui-input">
      </div>
    </div>
	<div class="layui-form-item">
		<label class="layui-form-label">所属部门</label>
		<div class="layui-input-block">
		  <div id="rolepid">
			  
		  </div>
		</div>
	</div>
    <div class="layui-form-item">
      <label class="layui-form-label">角色说明</label>
      <div class="layui-input-block">
        <textarea type="text" name="info" id="info" class="layui-textarea" placeholder="请输入角色具体说明">{$roles.info}</textarea>
      </div>
    </div>
    
    
    <div class="layui-form-item">
      <label class="layui-form-label">权限范围</label>
	<div class="layui-input-block">
	      <input type="checkbox" name="jurisdiction" lay-filter="roules" lay-skin="primary" value="/-all-/" title="所有权">
	</div>
    <div id="root" class="layui-input-block"></div>
    </div>
    <div class="layui-form-item layui-hide">
      <button class="layui-btn" lay-submit lay-filter="muyu-ajax-submit" id="muyu-ajax-submit">提交</button>
    </div>
  </div>

<!-- 低部区域 -->
{include file='public/footer'}
{load href="__ADMINST__muyuadmin/xm-select.js"}
  <script>
  layui.config({
    base: '__ADMINST__layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','tree'], function(){
    var $ = layui.$
    ,form = layui.form 
	,tree = layui.tree;
	
	//渲染
	var inst1 = tree.render({
	  elem: '#root'  //绑定元素
	  ,id: 'rootId' //定义索引
	  ,showCheckbox: true  //是否显示复选框
	  ,data: getData()//调用数据源函数获取数据
	});
	if({$roles['jurcheck']} === 1){
		//批量勾选
		tree.setChecked('rootId',[{$roleid}]);
		$("input[name='jurisdiction']").attr("checked", true);
	}else{
		tree.setChecked('rootId',[{$roles['jurisdiction']}]);
		$("input[name='jurisdiction']").attr("checked", false);
	}
	form.render();
	
	form.on('checkbox(roules)', function(data){
	  if(data.elem.checked){
		  tree.setChecked('rootId',[{$roleid}]);
	  }else{
		  tree.qxChecked('rootId');
	  }
	  form.render();
	});
  })
  var selectroles;
  lmqy1 = xmSelect.render({
  	el: '#rolepid',
  	model: { label: { type: 'text' } },
  	radio: true,
  	clickClose: true,
  	tree: {
  		show: true,
  		strict: false,
  		expandedKeys: [ -1 ],
  	},
  	height: 'auto',
  	data(){
  		return {$rolepids|raw}
  		}
  })
  //请求数据源
  function getData()
  {
      $.ajax({
          dataType:"json",
          type:"get",
          url:"{:url('Roles/getData')}",
          async:false,
          success:function(res){
              data = res;
          }
      });
      return data;
  }
  
  </script>
</body>
</html>